﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using NerdDinner.Models;

namespace NerdDinner.Controllers
{
    public class RSVPController : Controller
    {
        //
        // GET: /RSVP/
        DinnerRepository dinnerRepository = new DinnerRepository();
        [Authorize]
        public ActionResult Register(int id)
        {
            Dinner dinner = dinnerRepository.FindDinner(id);
            if (!dinner.IsUserRegistered(User.Identity.Name))
            {
                var rsvp = new RSVP();
                rsvp.AttendeeName = User.Identity.Name;
                dinner.RSVPs.Add(rsvp);
                dinnerRepository.Save();
            }

            return Content("Thinks - We'll see you there");
        }

    }
}
